package com.atguigu.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

public class ExcelListener extends AnalysisEventListener<User> {
    //一行一行读取Excel内容,把每行内容封装到user对象中
    //从第二行开始读取(默认认为第一行是表头)
    @Override
    public void invoke(User user, AnalysisContext analysisContext) {
        //user就是读到的内容(一行一行读取)
        System.out.println("数据:"+user);
    }
    //读取表头内容
    @Autowired
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头内容："+headMap);
    }
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {}
}
